﻿Imports MySql.Data.MySqlClient
Imports Microsoft.Win32
Imports System.Security
Imports System.IO
Imports ModLibrary.DataGridViewMultiColumnComboColumnDemo

Public Class All_Function_Cls
    Public Code_Check = "feaf6b9237f93a896ea4f85bb13ce352c3ccebb35d4864249b21de08642aa6ff4178b346e92kdmk203682"
    Private Conn As MySqlConnection = Nothing
    Private cmd As MySqlCommand = Nothing
    Dim textboxPemintaTanggal As TextBox
    Dim ParentaltextboxPemintaTanggal As Object


#Region " DGV Col DropDown Date & Multi Column "
    Public Sub DGVColDropDownDate(ByVal DGV As DataGridView, ByVal DisplayOnIndex As Integer, ByVal HeaderText As String, ByVal ColName As String, ByVal DataProperty As String, ByVal TextAlign As DataGridViewContentAlignment)
        ' buat dgv combo tangal 
        On Error Resume Next
        Dim cmb As New GridDateControl
        cmb.Width = 100
        cmb.HeaderText = HeaderText
        cmb.Name = ColName
        cmb.DataPropertyName = DataProperty
        'cmb.DefaultCellStyle.Format = APFCnst.Gl_Reg_Date_Format
        cmb.DefaultCellStyle.Alignment = TextAlign
        cmb.DisplayIndex = DisplayOnIndex
        DGV.Columns.Add(cmb)
    End Sub

    Public Sub DGVColDropDownMultCol(ByVal DGV As DataGridView, ByVal DisplayOnIndex As Integer, ByVal HeaderTextCol As String, ByVal DataProperty As String, ByVal Outer_DataSource As Object, ByVal Outer_DisplayMember As String, ByVal Outer_ValueMember As String, ByVal MaxDropDownItems As Integer, ByVal DropDownWidth As Integer, ByVal DisplayStyle As DataGridViewComboBoxDisplayStyle)
        On Error Resume Next
        ' buat kolom baru tuk akun 
        Dim newColumn As New DataGridViewMultiColumnComboColumn()
        newColumn.CellTemplate = New DataGridViewMultiColumnComboCell()
        newColumn.HeaderText = HeaderTextCol
        newColumn.DataPropertyName = DataProperty
        newColumn.DataSource = Outer_DataSource
        newColumn.DisplayMember = Outer_DisplayMember  ' Sumber Luar
        newColumn.ValueMember = Outer_ValueMember  ' Sumber Luar
        'newColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.[Nothing]
        newColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing
        newColumn.DisplayIndex = DisplayOnIndex
        newColumn.MaxDropDownItems = MaxDropDownItems
        newColumn.DropDownWidth = DropDownWidth
        DGV.Columns.Add(newColumn)
    End Sub
#End Region

    Public Sub DateBtn_Open(ByVal TextBoxPeminta As TextBox)
        On Error Resume Next
        Dim ShowTgl As New DateBox
        ShowTgl.TextBoxPemintaTanggal = TextBoxPeminta
        ShowTgl.TopMost = True
        ShowTgl.ShowDialog()
    End Sub


    Public Sub MoveNavi(ByVal Pilihan As String, ByVal Val4Pos As Integer, ByVal Pengirim As Object, ByVal BS As BindingSource)

        Select Case Pilihan
            Case "Load"
                Try
                    CType(Pengirim, Object).LoadNow()
                    BS.MoveLast()
                Catch ex As Exception
                    MsgBox(ex.Message.ToString)
                End Try
            Case "Add"
                If BS.Count = "0" Then
                    Try
                        BS.AddNew()
                    Catch ex As Exception
                    End Try
                Else
                    Try
                        BS.AddNew()
                    Catch ex As Exception
                    End Try
                End If
            Case "MoveFirst"
                BS.MoveFirst()
            Case "MovePrev"
                BS.MovePrevious()
            Case "MoveNext"
                BS.MoveNext()
            Case "MoveLast"
                BS.MoveLast()
            Case "MovePos"
                BS.Position = Val4Pos - 1
        End Select
    End Sub

End Class
